<?php

include_once "EventHandler.php";
include_once "gest_dptos/IUDptos.php";

class Application implements EventHandler {
    
    private $currentForm;
    
    function handleEvent($sender, $event) {
        $this->currentForm->handleEvent($sender, $event);
    }
    
    function setCurrentForm(EventHandler $form)
    {
        $this->currentForm = $form;
    }
    
    function getCurrentForm()
    {
        return $this->currentForm;
    }
    
}

session_start();

if (!isset($_SESSION["application"])) {
	$_SESSION["application"] = new Application();
	$currentForm = new IUDptos();
	$_SESSION["application"]->setCurrentForm($currentForm);
}

if (isset($_GET["_event_"])) {
    $_SESSION["application"]->handleEvent($_GET["_sender_"], $_GET["_event_"]);
}

$_SESSION["application"]->getCurrentForm()->mostrar();

?>